{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "89449977-6d2d-4174-affd-d2bf5f058159",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    名称     单价   数量\n",
      "0  小太阳  320.9  100\n",
      "1   鼠标  128.0   50\n",
      "2   小刀    1.5  200\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "## 列表方式创建DataFrame对像\n",
    "data=[['小太阳', 320.9, 100], ['鼠标', 128, 50], ['小刀', 1.5, 200]]\n",
    "columns=['名称', '单价', '数量']\n",
    "df=pd.DataFrame(data=data, columns=columns)\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4b67f3dd-dfe7-4fcc-9e27-dc2633ec4c35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    名称     单价   数量\n",
      "0  小太阳  320.0  100\n",
      "1   鼠标  120.0   20\n",
      "2   小刀    1.5  200\n"
     ]
    }
   ],
   "source": [
    "# 字典的方式创建DataFrame对象\n",
    "data={'名称':['小太阳', '鼠标', '小刀'],'单价':[320,120,1.5],'数量':[100,20,200]}\n",
    "df=pd.DataFrame(data=data)\n",
    "print(df)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
